Skip to content

feat(integrations): wire github finish setup from posthog code#2215

Open
Twixes wants to merge 1 commit into
mainfrom
fix/github-integration-finish-setup
Open

feat(integrations): wire github finish setup from posthog code#2215
Twixes wants to merge 1 commit into
mainfrom
fix/github-integration-finish-setup

Conversation

@Twixes
Copy link
Copy Markdown
Member

@Twixes Twixes commented May 19, 2026

Summary

  • Call PostHog github/finish_setup from the GitHub integration settings flow after App install/update
  • Add githubInstallationSettingsUrl helper for org vs user installation settings links
  • Wire prepare_callback before redirecting to GitHub authorize when connecting from Code

Test plan

  • Connect GitHub from PostHog Code settings (fresh install)
  • Re-run GitHub App setup for an existing installation (setup_action=update)
  • Open installation settings link for org and user installs

Split from posthog-code/signals-inbox-slack-notifications; pairs with PostHog fix/github-integration-finish-setup.

…s urls

Add githubInstallationSettingsUrl helper and connect PostHog client finish_setup
for GitHub App installation flow from notification settings.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 19, 2026

Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
apps/code/src/renderer/features/settings/components/sections/GitHubIntegrationSection.tsx:48-52
**Silent failure gives no user feedback**

When `prepareGithubTeamIntegrationCallback` throws, the `catch` block silently returns. The user clicks "Update in GitHub" and nothing happens — no GitHub tab opens, no error message appears. At minimum the error should be surfaced (e.g. a toast), otherwise users are left believing the click registered when it didn't.

### Issue 2 of 3
apps/code/src/renderer/features/integrations/utils/githubInstallationSettingsUrl.test.ts:26-51
Three distinct input/output cases are bundled in a single `it` with multiple `expect` calls. The project explicitly prefers parameterised tests — if the first assertion fails the remaining cases are never run, making it harder to pinpoint regressions. Using `it.each` gives each case an independent result and a descriptive name.

```suggestion
describe("resolveGithubInstallationId", () => {
  it.each([
    [
      "prefers top-level installation_id over integration_id and config",
      { id: 99, kind: "github", installation_id: "a", config: { installation_id: "c" } },
      "a",
    ],
    [
      "falls back to integration_id when installation_id is absent",
      { id: 1, kind: "github", integration_id: 12345 },
      "12345",
    ],
    [
      "falls back to config.installation_id as last resort",
      { id: 1, kind: "github", config: { installation_id: "c" } },
      "c",
    ],
  ])("%s", (_label, input, expected) => {
    expect(resolveGithubInstallationId(input as Parameters<typeof resolveGithubInstallationId>[0])).toBe(expected);
  });
});
```

### Issue 3 of 3
apps/code/src/renderer/api/posthogClient.ts:664
Redundant status guard — `response.ok` is already `true` for every 2xx response including 204, so `&& response.status !== 204` can never change the outcome of the outer `!response.ok` check. Per simplicity rule 4, this is a superfluous part.

```suggestion
    if (!response.ok) {
```

Reviews (1): Last reviewed commit: "feat(integrations): wire github finish s..." | Re-trigger Greptile

Comment on lines +48 to +52
try {
await client.prepareGithubTeamIntegrationCallback(projectId, nextPath);
} catch {
return;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Silent failure gives no user feedback

When prepareGithubTeamIntegrationCallback throws, the catch block silently returns. The user clicks "Update in GitHub" and nothing happens — no GitHub tab opens, no error message appears. At minimum the error should be surfaced (e.g. a toast), otherwise users are left believing the click registered when it didn't.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/settings/components/sections/GitHubIntegrationSection.tsx
Line: 48-52

Comment:
**Silent failure gives no user feedback**

When `prepareGithubTeamIntegrationCallback` throws, the `catch` block silently returns. The user clicks "Update in GitHub" and nothing happens — no GitHub tab opens, no error message appears. At minimum the error should be surfaced (e.g. a toast), otherwise users are left believing the click registered when it didn't.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +26 to +51
describe("resolveGithubInstallationId", () => {
it("prefers top-level installation_id then id then config", () => {
expect(
resolveGithubInstallationId({
id: 99,
kind: "github",
installation_id: "a",
config: { installation_id: "c" },
}),
).toBe("a");
expect(
resolveGithubInstallationId({
id: 1,
kind: "github",
integration_id: 12345,
}),
).toBe("12345");
expect(
resolveGithubInstallationId({
id: 1,
kind: "github",
config: { installation_id: "c" },
}),
).toBe("c");
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Three distinct input/output cases are bundled in a single it with multiple expect calls. The project explicitly prefers parameterised tests — if the first assertion fails the remaining cases are never run, making it harder to pinpoint regressions. Using it.each gives each case an independent result and a descriptive name.

Suggested change
describe("resolveGithubInstallationId", () => {
it("prefers top-level installation_id then id then config", () => {
expect(
resolveGithubInstallationId({
id: 99,
kind: "github",
installation_id: "a",
config: { installation_id: "c" },
}),
).toBe("a");
expect(
resolveGithubInstallationId({
id: 1,
kind: "github",
integration_id: 12345,
}),
).toBe("12345");
expect(
resolveGithubInstallationId({
id: 1,
kind: "github",
config: { installation_id: "c" },
}),
).toBe("c");
});
});
describe("resolveGithubInstallationId", () => {
it.each([
[
"prefers top-level installation_id over integration_id and config",
{ id: 99, kind: "github", installation_id: "a", config: { installation_id: "c" } },
"a",
],
[
"falls back to integration_id when installation_id is absent",
{ id: 1, kind: "github", integration_id: 12345 },
"12345",
],
[
"falls back to config.installation_id as last resort",
{ id: 1, kind: "github", config: { installation_id: "c" } },
"c",
],
])("%s", (_label, input, expected) => {
expect(resolveGithubInstallationId(input as Parameters<typeof resolveGithubInstallationId>[0])).toBe(expected);
});
});
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/integrations/utils/githubInstallationSettingsUrl.test.ts
Line: 26-51

Comment:
Three distinct input/output cases are bundled in a single `it` with multiple `expect` calls. The project explicitly prefers parameterised tests — if the first assertion fails the remaining cases are never run, making it harder to pinpoint regressions. Using `it.each` gives each case an independent result and a descriptive name.

```suggestion
describe("resolveGithubInstallationId", () => {
  it.each([
    [
      "prefers top-level installation_id over integration_id and config",
      { id: 99, kind: "github", installation_id: "a", config: { installation_id: "c" } },
      "a",
    ],
    [
      "falls back to integration_id when installation_id is absent",
      { id: 1, kind: "github", integration_id: 12345 },
      "12345",
    ],
    [
      "falls back to config.installation_id as last resort",
      { id: 1, kind: "github", config: { installation_id: "c" } },
      "c",
    ],
  ])("%s", (_label, input, expected) => {
    expect(resolveGithubInstallationId(input as Parameters<typeof resolveGithubInstallationId>[0])).toBe(expected);
  });
});
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

body: JSON.stringify({ next }),
},
});
if (!response.ok && response.status !== 204) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Redundant status guard — response.ok is already true for every 2xx response including 204, so && response.status !== 204 can never change the outcome of the outer !response.ok check. Per simplicity rule 4, this is a superfluous part.

Suggested change
if (!response.ok && response.status !== 204) {
if (!response.ok) {
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/api/posthogClient.ts
Line: 664

Comment:
Redundant status guard — `response.ok` is already `true` for every 2xx response including 204, so `&& response.status !== 204` can never change the outcome of the outer `!response.ok` check. Per simplicity rule 4, this is a superfluous part.

```suggestion
    if (!response.ok) {
```

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant